import { resolve } from 'node:path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import eslintPlugin from 'vite-plugin-eslint';

export default defineConfig({
  resolve: {
    alias: [
      { find: /^~/, replacement: '' },
      { find: '@', replacement: resolve(__dirname, './src') },
    ],
  },
  plugins: [
    react(),
    eslintPlugin(),
  ],
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      },
    },
  },
  server: {
    host: '0.0.0.0',
    port: 9999,
    open: true,
    cors: true,
    proxy: {
      '/api': {
        target: 'http://localhost:9998',
        changeOrigin: true,
      },
    },
  },
});
